﻿using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using WpfAppDemo.dataContext;

namespace WpfAppDemo
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            List<MenuData> names = new List<MenuData>();

            names.Add(new MenuData("IndianRed", "#CD5C5C"));
            names.Add(new MenuData("LightCoral", "#F08080"));
            names.Add(new MenuData("Salmon", "#FA8072"));
            names.Add(new MenuData("DarkSalmon", "#E9967A"));
            menuList.ItemsSource = names;
            menuList2.ItemsSource = names;

            this.DataContext = new MyDataContext();


            playAnimation(box1);
            playAnimation(box2);
            playAnimation(box3);
            playAnimation(box4);
            playAnimation(box5);
        }

        /*
         播放简单动画
         */
        private void playAnimation(Control control) {

            ThicknessAnimation boxAnimation = new ThicknessAnimation();

            boxAnimation.From = new Thickness(80, 40, 80, 40);
            boxAnimation.To = control.Margin;
            boxAnimation.Duration = TimeSpan.FromSeconds(2);


            control.BeginAnimation(Control.MarginProperty, boxAnimation);
        }


        private void Binding_Button_Click(object sender, RoutedEventArgs e)
        {
            DataBinding dataBinding = new DataBinding();

            dataBinding.Show();
        }

        private void OpenMvvmLightWindow(object sender, RoutedEventArgs e) {

            MvvmLightWindow mvvmLightWindow = new MvvmLightWindow();

            mvvmLightWindow.Show();
        }
    }

    class MenuData { 
    
        public string Name { get; set; }
        public string Color { get; set; }

        public MenuData(string name, string color)
        {
            Name = name;
            Color = color;
        }
    }
}